﻿using System.Windows;
using System.Windows.Controls;

namespace UpdaterForm
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            LoadUpdatesData();
        }

        private void LoadUpdatesData()
        {
            foreach (var app in AppCahce.Conf.Data.AppData)
            {
                var appTab = new AppControl(app);
                var tab = new TabItem{
                    Header = app.AppName, 
                    Content = appTab
                };
                SupportedApp.Items.Add(tab);
            }
        }

        private void MainForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            foreach (var data in AppCahce.Conf.Data.AppData)
            {
                data.SaveLogs();
            }
            AppCahce.SaveConf();
        }
    }
}
